{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "5af13da6-b846-4f60-b7b9-f9880c26ca93",
   "metadata": {},
   "source": [
    "Chapter 08\n",
    "# 产生全0矩阵\n",
    "Book_1《编程不难》 | 鸢尾花书：从加减乘除到机器学习 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "7ab2ff86-e1c6-4b7c-9491-7bb4aca6826f",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 自定义函数产生全0矩阵\n",
    "def create_zeros_matrix(rows, cols):\n",
    "    matrix = []\n",
    "    for _ in range(rows):\n",
    "        row_idx = [0] * cols\n",
    "        matrix.append(row_idx)\n",
    "    return matrix"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "de994ccb-9450-4818-b3a9-da1698d1330d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 调用自定义函数\n",
    "create_zeros_matrix(3, 4)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
